-- simple dog to use with animal mobs !!!
-- This is a " kitten " version of the animal mobs, with some minor modifications.
-- sounds : 
-- https://freesound.org/people/ScouseMouseJB/sounds/276267/
-- https://freesound.org/people/TobiasKosmos/sounds/163280/
local getInitialName = function(mobName)
	local isShowed = minetest.settings:get_bool("simpleanimals.initial_nametags")
	if isShowed then
		return mobName
	end
end

mobs:register_mob("dog:dog", {
	nametag = getInitialName("DOG"),
	type = "animal",
	specific_attack = {
		--"mobs_animal:kkitten",
		"mobs_skeletons:skeleton",
		"mobs_skeletons:skeleton_archer",
		"mobs_skeletons:skeleton_archer_dark",
	},
   damage = 3,
	attack_type = "dogfight",
	--attack_animals = true, -- so it can attack kitten?
	group_attack = true,
	reach = 2,
	stepheight = 1.1,
	passive = false,
	hp_min = 10,
	hp_max = 10,
	armor = 100,
	collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.1, 0.3},
	visual = "mesh",
	visual_size = {x = 0.5, y = 0.5},
	mesh = "dog.b3d",
	rotate = 180,
	textures = {
		{"dog.png"},
		{"dog_black.png"},
		{"dog_yellow.png"},
		{"dog_tabby.png"},
		
	},
	makes_footstep_sound = false,
	sounds = {
		random = "bark",
		death = "yelp",
	},
	walk_velocity = 2,
	walk_chance = 15,
	run_velocity = 3,
	runaway = true,
	jump = true,
	jump_height = 2,
	stepheight = 1,
	drops = {
		--{name = "", chance = 1, min = 0, max = 1},
		{name = 'bonemeal:bone', chance = 20, min = 0, max = 2}
	},
	water_damage = 1, --dogs unlike of water.
	lava_damage = 5,
	fear_height = 3,
	animation = {
		speed_normal = 20, -- 42
		--stoodup_start = 0,
		--stoodup_end = 0,
		walk_start = 20,
		walk_end = 40,
		stand_start = 50,
		stand_end = 109,
	},
	follow = {
		"mobs:chicken_raw", 
		"mobs:meat_raw",
		"bonemeal:bone",
	},
	view_range = 10,
	runaway = true , 

	on_rightclick = function(self, clicker)

		if mobs:feed_tame(self, clicker, 4, true, true) then return end
		if mobs:protect(self, clicker) then return end
		if mobs:capture_mob(self, clicker, 50, 50, 90, false, nil) then return end

		-- by right-clicking owner can switch between staying and walking
		if self.owner and self.owner == clicker:get_player_name() then
			minetest.sound_play("bark", {pos=self.object:get_pos(), gain=1.0, max_hear_distance = 5})
			if self.order ~= "stand" then
				self.order = "stand"
				self.state = "stand"
				self.object:set_velocity({x = 0, y = 0, z = 0})
				mobs:set_animation(self, "stand")
			else     
				self.order = ""
				mobs:set_animation(self, "walk")
			end
		end
	end,

	
})


if not mobs.custom_spawn_animal then
mobs:spawn({
	name = "dog:dog",
	nodes = {
		"default:dirt_with_grass",
		"ethereal:grove_dirt",
	},
	--neighbors = {"group:grass"},
	min_light = 4, --dogs hanter in night
	interval = 60,
	chance = 8000, --same the cat
	min_height = -5, --dogs exolore dig in surfaces caves
	max_height = 50,
	--day_toggle = true,
})
end


mobs:register_egg("dog:dog", "Dog", "dog_egg.png", 1)




